home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-13 | 2.6 KB | 129 lines | [TEXT/MPS ] |
- {
- say - a sample program illustrating the use of MacinTalk
- in a MPW tool. This tool will route standard input
- through MacinTalk.
-
- disclaimer: this program was written hastely and should
- not be thought of as a very good example
-
- parameters:
- -d debug = on
- -m mode = robotic
- -r n rate = n
- -p n rate = p
-
- example usage:
- Directory | say
-
- by Paul Mercer, 3/86
- modified 7/87 for inclusion in MacinTalk 1.31 release
- }
-
-
- PROGRAM say;
-
- USES
- MemTypes, QuickDraw, OSIntf, ToolIntf, PasLibIntf, IntEnv, Signal,
- SpeechIntf; {Macintalk interface}
-
- VAR
- instr: str255;
- theSpeech: SpeechHandle; {handle to speech globals}
- SErr: SpeechErr;
- output: Handle; {handle to phonetic string}
- debug: boolean;
- theMode: F0Mode;
-
-
- PROCEDURE SayIt;
-
- BEGIN
- IF debug THEN
- WriteLn('converting text to phonemes');
- SErr := Reader(theSpeech, pointer(ORD4(@instr)+1), ORD(instr[0]), output);
- IF debug THEN
- WriteLn('speaking the phonemes');
- SErr := MacinTalk(theSpeech, output); {say it.}
- END; {SayIt}
-
-
- PROCEDURE MyExit;
-
- BEGIN
- IF debug THEN
- WriteLn('closing Macintalk');
- SpeechOff(theSpeech); {close the speech driver.}
- DisposHandle(output); {release the output handle}
- END; {MyExit}
-
-
- PROCEDURE str2int(instr: str255; VAR inInt: integer);
-
- VAR
- i,j: Integer;
-
- BEGIN
- j := 1;
- inInt := 0;
- FOR i := ORD(instr[0]) DownTo 1 DO
- BEGIN
- inint := inint + (j * (ORD(instr[i]) - ORD('0')));
- j := j*10;
- END;
- END; {str2Int}
-
-
- { main program starts here }
- VAR
- x,y: integer;
-
- BEGIN
- SErr := SpeechOn(noExcpsFiles, theSpeech); {Open the speech driver}
- IF SErr <> 0 THEN WriteLn('Error opening Macintalk: ', SErr);
- theMode := Natural;
- SpeechPitch(theSpeech, 0, theMode);
- debug := False;
- FOR x := 0 to ArgC-1 DO
- BEGIN
- IF (ArgV^[x]^ = '-d') or (ArgV^[x]^ = '-D') THEN
- debug := True;
-
- IF (ArgV^[x]^ = '-M') or (ArgV^[x]^ = '-m') THEN
- BEGIN
- IF debug THEN
- WriteLn('mode is Robotic');
- theMode := Robotic;
- SpeechPitch(theSpeech, 0, theMode);
- END;
-
- IF (ArgV^[x]^ = '-r') or (ArgV^[x]^ = '-R') THEN
- BEGIN
- str2int(ArgV^[x+1]^, y);
- IF debug THEN WriteLn('rate is: ', y);
- SpeechRate(theSpeech, y);
- END;
-
- IF (ArgV^[x]^ = '-p') or (ArgV^[x]^ ='-P') THEN
- BEGIN
- str2int(ArgV^[x+1]^, y);
- IF debug THEN WriteLn('pitch is: ', y);
- SpeechPitch(theSpeech, y, NoChange);
- END
- END; {FOR x}
-
- IF debug THEN
- WriteLn('now disabling signals.');
- SErr := IEsighold(SIGALLSIGS); {disable signals}
-
- output := NewHandle(0);
- REPEAT
- BEGIN
- IF debug THEN
- WriteLn('awaiting input');
- ReadLn(instr);
- SayIt;
- END
- UNTIL EOF;
- MyExit;
- END.
-